package com.luxondata.module.masterdata.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.luxondata.module.masterdata.entry.Product;
import com.luxondata.module.masterdata.service.ProductService;

@RestController
@RequestMapping("/product")
public class ProductController {

	@Autowired
	private ProductService productService;
	
	/**
	 * 获取所有数据
	 * @return
	 */
	@RequestMapping(value = "/listall", method = RequestMethod.GET)
	public List<Product> list() {
		return productService.getAll();
	}
	
	/**
	 * 保存实体
	 * @param product
	 * @return
	 */
	@RequestMapping(value = "/save", method = RequestMethod.GET)
	public Product save(Product product) {
		return productService.save(product);
	}
	
	/**
	 * 根据id删除实体
	 * @param id
	 */
	@RequestMapping(value = "/delete", method = RequestMethod.GET)
	public void delete(Long id) {
		productService.delete(id);
	}
	

}
